// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLSubPartitionByList.h"
#include "../visitor/SQLASTVisitor.h"
#include "SQLName.h"

// @Override
void SQLSubPartitionByList::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLSubPartitionByList)))
  {
    acceptChild(visitor, column);
    acceptChild(visitor, subPartitionsCount);
  }
  visitor->endVisit(SharedObject(SQLSubPartitionByList));
}

SQLName_ptr SQLSubPartitionByList::getColumn()
{
  return column;
}

void SQLSubPartitionByList::setColumn(SQLName_ptr column)
{
  if (column != nullptr)
  {
    column->setParent(SharedObject(SQLSubPartitionByList));
  }
  this->column = column;
}

SQLObject_ptr SQLSubPartitionByList::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<SQLSubPartitionByList>(new SQLSubPartitionByList());
  std::shared_ptr<SQLSubPartitionByList> x = std::dynamic_pointer_cast<SQLSubPartitionByList>(clone_tmp);
  // SQLSubPartitionByList x = new SQLSubPartitionByList();
  if (column != nullptr)
  {
    x->setColumn(std::dynamic_pointer_cast<SQLName>(column->clone()));
  }
  return x;
}

BOOL_ptr SQLSubPartitionByList::isPartitionByColumn(long columnNameHashCode64)
{
  return (column != nullptr && column->nameHashCode64() == columnNameHashCode64)?BOOL::TRUE:BOOL::FALSE;
}
